<?php
class RankEngineAlexa extends LogicRankEngine
{
	/**
	 * @param string $url
	 * @return SeoSiteRank
	 */
	public function process($url)
	{
		$alexaxml = "http://xml.alexa.com/data?cli=10&dat=nsa&url=$url";
		
		$xml_parser = xml_parser_create();
		$data=file_get_contents($alexaxml);
		xml_parse_into_struct($xml_parser, $data, $vals, $index);
		xml_parser_free($xml_parser);
		
		$index_popularity = $index['POPULARITY'][0];
		$alexarank = $vals[$index_popularity]['attributes']['TEXT'];
		
		$rank = new SeoSiteRank();
		$rank->setEngineType($this->getType());
		$rank->setRank($alexarank);
		return $rank;
	}
}